package com.sunthy.mall.utils;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @Description: 获取自己的IP的工具类
 * @Author: XM
 */
public class MyIPUtils {

    /**
     * 获取配置文件的origin
     *
     * @return origin
     */
    public static String getOrigin() {
        Properties properties = new Properties();
        String origin = new String();
        try {
            InputStream resourceAsStream = MyIPUtils.class.getClassLoader().getResourceAsStream("application.properties");
            properties.load(resourceAsStream);
            origin = properties.getProperty("origin");
            resourceAsStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return origin;
    }

    /**
     * 获取配置文件的domain
     *
     * @return domain
     */
    public static String getDomain() {
        Properties properties = new Properties();
        String domain = new String();
        try {
            InputStream resourceAsStream = MyIPUtils.class.getClassLoader().getResourceAsStream("application.properties");
            properties.load(resourceAsStream);
            domain = properties.getProperty("domain");
            resourceAsStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return domain;
    }
}
